<body>
<script src="../modules/emitify/lib/emitify.js"></script>
<script src="../modules/findit/lib/findit.js"></script>
<script src="../lib/philip.js"></script>
<script>
(function() {
    'use strict';
    
    var node = window;
    
    node.addEventListener('drop', function (e) {
        var upload,
            entry,
            finder,
            item = e.dataTransfer.items[0];
        
        e.preventDefault();
        
        entry   = item.webkitGetAsEntry();
        
        upload = philip(entry, function(type, name, data, callback) {
            var error = null;
            
            switch(type) {
            case 'file':
                console.log('file', name, data);
                break;
            
            case 'directory':
                console.log('directory', name);
                break;
            }
            
            callback(error);
        });
        
        upload.on('error', function(error) {
            console.error(error);
        });
        
        upload.on('progress', function(count) {
            console.log(count);
        });
        
        upload.on('end', function() {
            console.log('done');
        });
    });
        
    node.addEventListener('dragover', function (e) {
        e.preventDefault();
    });
})();
</script>
</body>
